/* 
 * File:   main.cpp
 * Author: filiagees
 *
 * Created on March 9, 2013, 11:21 PM
 */

#include <cstdlib>
#include <iostream>
#include <cstdio>

#include "src/Controle_gui.h"
#include "src/Utils.h"
#include "src/Quadrado.h"

using namespace std;

void displayCallBack();

/* SCV: Chuck Noris v2 
 * YO!
 */
int main(int argc, char** argv) {
    Controle_gui *gui = new Controle_gui();
   
    srand( time(0) );
     
    gui->init(argc, argv, displayCallBack);   
    
    cout << "->\trand_num()\n";
    cout << Utils::rand_num(0,1) << endl;
    cout << Utils::rand_num(0,1)<< endl;
    cout << Utils::rand_num(0,1)<< endl;
    cout << Utils::rand_num(0,1)<< endl;
    cout << Utils::rand_num(0,1)<< endl;

    cout << "->\trand_color()\n";
    float r,g,b,a;
    Utils::rand_color(&r,&g,&b,&a);
    printf("(%.3f, %.3f, %.3f, %.3f)\n", r,g,b,a);
    
    Quadrado *q = new Quadrado();
    int pX=1, pY=50;
    cout << "->\tQuadrado:";
    printf("(xSupEsq=%d,ySupEsq=%d) | (xInfDir=%d,yInfDir=%d)\n", 
          q->xSupEsq, q->ySupEsq, q->xInfDir, q->yInfDir);
    
    if( q->is_point_inside(pX, pY) == true ){
        printf("(x=%d,y=%d) -> dentro",pX,pY);
    }else{
        printf("(x=%d,y=%d) -> fora",pX,pY);
    }
    cout <<endl;
    
    return 0;
}

void displayCallBack(){
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0, 500, 0, 500, -2.0, 100.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  gluLookAt(0, 0, 20 , 0.0, 0.0, 0.0 , 0.0, 1.0, 0.0);
  
  glColor3f(1,1,0);
  Quadrado *q = new Quadrado();
  
  /*
  glScalef(.005,.005,.005);
  glRotatef(20, 0, 1, 0);
  glRotatef(30, 0, 0, 1);
  glRotatef(5, 1, 0, 0);
  glTranslatef(-300, 0, 0);
  */
  
  /*
  glutStrokeCharacter(GLUT_STROKE_ROMAN, 'H');
  */
      
  glutSwapBuffers();
}
